package com.octopus.kernal.ui.element;

import java.lang.reflect.InvocationTargetException;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.beanutils.BeanUtils;

@SuppressWarnings("serial")
@XmlType(name="TimeElement")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class TimeElement extends InputElement{

	public String getName() {
		if(super.getName() == null)
			return null;
		else if(super.getName().lastIndexOf("Str") == (super.getName().length() - 3))
			return super.getName();
		else
			return super.getName() + "Str";
	}

	public String getOnfocus() {
		return "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})";
	}

	public String getCssclass() {
		return "Wdate";
	}
	
	public TimeElement clone(){
		TimeElement result = new TimeElement();
		try {
			BeanUtils.copyProperties(result, this);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return result;
	}

}
